Imports System.Data.SqlClient
Imports System.Drawing
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Views.Base
Imports DevExpress.XtraGrid.Columns
Imports DevExpress.XtraEditors
Imports DevExpress.XtraScheduler
Imports DevExpress.XtraScheduler.UI
Imports DevExpress.XtraGrid.Views.Grid

'--- Created Date On : 24-Sep-2010 (Jagdish)

Public Class frmDrugDetails
    Dim mstrMode As String
    Public blnAdd As Boolean, blnEdit As Boolean, blnDelete As Boolean, blnLocked As Boolean
    Dim mlngRecordID As Long
    Dim blnUnload As Boolean
    Dim mblnChanged As Boolean
    Dim mblnActivate As Boolean
    Dim mblnExpanded As Boolean = False
    Dim mblnAutoSize As Boolean = True
    Dim mblnIsImported As Boolean
    Dim gridView1 As Views.Grid.GridView
    Dim mblnCancelDisplay As Boolean
    Public mlngDrugId As Long
    Public mstrMenuList(4)() As String    'Keeps menu details (Jagged Arrays)

    Private Sub initializeMenu()
        Try
            'Middle -1 Group
            'Middle -2 Locked

            'Last -1 Checked

            mstrMenuList(0) = New String() {"Main", 1, 0, "Main"}

            mstrMenuList(1) = New String() {"Drug Name", 2, 1, "DrugName"}
            mstrMenuList(2) = New String() {"Theraputic Class", 2, 1, "TheraputicClass"}
            mstrMenuList(3) = New String() {"Pharamcy Class", 2, 1, "PharamcyClass"}

        Catch ex As Exception
            MessageBox.Show(ex.Message, gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Error)
            AddErrorLog("Error " & Err.Number & " (" & Err.Description & ") in Procedure " & _
                Reflection.MethodBase.GetCurrentMethod.Name & " Of " & Me.Name)
        End Try
    End Sub

    Private Sub frmDrugDetails_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
        Try
            If mblnActivate = True Then
                mblnActivate = False

                pbRecords.Visible = True
                pbRecords.BringToFront()
                Application.DoEvents()
                pbRecords.Position = 20

                Call SetEditorDosage()
                Call SetEditorSideEffect()
                'Fill Drug combo
                Call PopulateLookupDX(lkDrug, "DrugName", "DrugId", "LtblDrugs L,tblDrugs D", "L.DrugId, L.DrugName", "L.DrugId=D.DrugId and D.DrugDeleted=0", "L.DrugName")
                'Fill Therapeutic Class
                Call PopulateLookupDX(lkTherapeuticClass, "TherapeuticClass", "ClassID", "LtblTherapeuticClasses", "ClassID, TherapeuticClass", , "TherapeuticClass", True)
                'Fill Pharmacy Class
                Call PopulateLookupDX(lkPharmacyClass, "PharmacyClass", "ClassID", "LtblPharmacyClasses", "ClassID, PharmacyClass", , "PharmacyClass", True)
                Call PopulateData()
                If mlngDrugId > 0 Then
                    mlngRecordID = mlngDrugId
                    Call SetRowFromOutside(mlngDrugId)
                End If
                pbRecords.Position = 100
                pbRecords.Visible = False
                grdRecords.Focus()
            End If

        Catch ex As Exception
            pbRecords.Visible = False
            MessageBox.Show(ex.Message, gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Error)
            AddErrorLog("Error " & Err.Number & " (" & Err.Description & ") in Procedure " & _
                Reflection.MethodBase.GetCurrentMethod.Name & " Of " & Me.Name)
        End Try
    End Sub

    Private Sub frmDrugDetails_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Try

            Dim intUnload As DialogResult

            If mblnChanged = True And mstrMode <> "" Then
                intUnload = MessageBox.Show("You have not saved your changes to the record. Do you want to save your changes now?", gstrMessage, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)
                If intUnload = Windows.Forms.DialogResult.Cancel Then
                    e.Cancel = True : Exit Sub
                ElseIf intUnload = Windows.Forms.DialogResult.Yes Then
                    blnUnload = True
                    If blnSaveRecords() = False Then
                        e.Cancel = True
                        blnUnload = False
                        Exit Sub
                    End If
                    mblnChanged = False
                End If
            End If
            blnUnload = False

        Catch ex As Exception
            blnUnload = False
            MessageBox.Show(ex.Message, gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Error)
            AddErrorLog("Error " & Err.Number & " (" & Err.Description & ") in Procedure " & _
                Reflection.MethodBase.GetCurrentMethod.Name & " Of " & Me.Name)
        End Try
    End Sub

    Private Sub frmDrugDetails_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        mblnCancelDisplay = True
        If blnKeyTrap(e.KeyCode, Me, True, grdRecords) = True Then mblnCancelDisplay = False : Exit Sub
        mblnCancelDisplay = False

        If e.KeyCode = Keys.F5 Then
            gdvRecords_FocusedRowChanged(Nothing, Nothing)
        End If

        pbRecords.Visible = False
    End Sub

    Private Sub frmDrugDetails_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try

            Call SetImageControl(Me)
            Me.Icon = System.Drawing.Icon.FromHandle(CType(mdiMain.imgFormIcons.Images(2), Bitmap).GetHicon())
            Call btnExpand_Click(Me, e)
            Call GetAccessPermission(Me, "frmDrugDetails")
            Call initializeMenu()
            rgSelect.SelectedIndex = 0
            lkDrug.Visible = True
            Call setPBRecords(Me, pbRecords)
            mblnActivate = True
            mblnChanged = False

        Catch ex As Exception
            MessageBox.Show(ex.Message, gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Error)
            AddErrorLog("Error " & Err.Number & " (" & Err.Description & ") in Procedure " & _
                Reflection.MethodBase.GetCurrentMethod.Name & " Of " & Me.Name)
        End Try
    End Sub

    Public Sub PopulateData()
        Dim dsRecords As New DataSet   'For populating data in XtraGrid
        Dim strQuery As String = ""
        Dim strTemp As String = ""
        Dim intCtr As Int16

        Try
            pbRecords.Position = 40 : Application.DoEvents()

            For intCtr = 0 To mstrMenuList.GetUpperBound(0) - 1
                If mstrMenuList(intCtr)(1) <> 1 And mstrMenuList(intCtr)(2) <> 0 Then
                    strTemp = mstrMenuList(intCtr)(3)
                    strQuery = strQuery & "," & strTemp & " [" & mstrMenuList(intCtr)(0) & "]"
                End If
            Next

            strQuery = "select DrugId [record_id]" & strQuery & ",IsImported From tblDrugs Where DrugDeleted=0 "

            If rgSelect.SelectedIndex = 0 And Val(lkDrug.EditValue) > 0 Then
                strQuery = strQuery & "  And DrugId=" & lkDrug.EditValue
            ElseIf rgSelect.SelectedIndex = 1 And lkTherapeuticClass.Text <> "" Then
                strQuery = strQuery & " And TheraputicClass='" & lkTherapeuticClass.Text & "'"
            ElseIf rgSelect.SelectedIndex = 2 And lkPharmacyClass.Text <> "" Then
                strQuery = strQuery & " And PharamcyClass='" & lkPharmacyClass.Text & "'"
            End If

            dsRecords = FillDataSet(strQuery)
            'Bind the grid control to the data source
            gdvRecords.Columns.Clear()

            With grdRecords
                .BeginUpdate()
                .DataSource = dsRecords.Tables(0)
                .EndUpdate()
                .ForceInitialize()
            End With

            With gdvRecords
                'Primary Key Field
                .Columns("record_id").Visible = False
                .Columns("record_id").OptionsColumn.ShowInCustomizationForm = False
                .Columns("IsImported").Visible = False
                .Columns("IsImported").OptionsColumn.ShowInCustomizationForm = False
                .ExpandAllGroups()
                .BestFitColumns()
            End With

            dsRecords.Dispose()
            pbRecords.Position = 80 : Application.DoEvents()

            'To set row count
            Call gdvRecords_ColumnFilterChanged(Nothing, Nothing)

        Catch ex As Exception
            MessageBox.Show(ex.Message, gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Error)
            AddErrorLog("Error " & Err.Number & " (" & Err.Description & ") in Procedure " & _
                Reflection.MethodBase.GetCurrentMethod.Name & " Of " & Me.Name)
        End Try
    End Sub

    Public Sub btnExpand_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExpand.Click
        If mblnExpanded = True Then
            mblnExpanded = False
            btnExpand.Image = mdiMain.imgEditIcons.Images(0)
            grdRecords.Width = 197
            Call btnCancel_Click(Nothing, Nothing)
        Else
            mblnExpanded = True
            btnExpand.Image = mdiMain.imgEditIcons.Images(1)
            grdRecords.Width = 802 : grdRecords.BringToFront()
            If gdvRecords.RowCount > 0 Then mlngRecordID = lngGetSelectID(gdvRecords, "record_id")
        End If

        If mblnAutoSize = True Then
            gdvRecords.OptionsView.ColumnAutoWidth = (mblnExpanded = True)
        End If
        grdRecords.Focus()
    End Sub

    Private Sub DisplayData()
        'Display data in form fields.
        Dim dsTemp As DataSet
        Dim strText As String = ""
        Dim strOut As String = ""
        Try

            dsTemp = FillDataSet("select * from tblDrugs where DrugID=" & mlngRecordID)

            With dsTemp.Tables(0)
                If .Rows.Count > 0 Then
                    txtDrugName.Text = Trim(.Rows(0).Item("DrugName") & "")
                    txtCategory.Text = Trim(.Rows(0).Item("Category") & "")
                    txtTherapeuticClass.Text = Trim(.Rows(0).Item("TheraputicClass") & "")
                    txtPharmacyClass.Text = Trim(.Rows(0).Item("PharamcyClass") & "")
                    mblnIsImported = .Rows(0).Item("IsImported")
                End If
            End With
            dsTemp.Dispose()

            Call GetIndicators()

            Call GetTherepeutics()

            Call GetContraIndicators()

            Call GetCautions()
            Call GetActions()
            Call GetSideEffects()
            Call GetDose()

        Catch ex As Exception
            MessageBox.Show(ex.Message, gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Error)
            Call AddErrorLog("Error " & Err.Number & " (" & Err.Description & ") in Procedure " & _
                 Reflection.MethodBase.GetCurrentMethod.Name & " Of " & Me.Name)
        End Try
    End Sub
    Private Sub GetIndicators()
        Dim dsTemp As DataSet
        Dim strText As String = ""
        Dim strOut As String = ""

        dsTemp = FillDataSet("Select Indication from tblDrugIndications where DrugID=" & mlngRecordID)
        With dsTemp.Tables(0)
            'If .Rows.Count > 0 Then
            '    txtIndicators.Text = .Rows(0).Item("Indication")
            'End If
            For intCtr As Integer = 0 To .Rows.Count - 1
                strText = .Rows(intCtr).Item("Indication")
                strText = strText.Replace(Chr(13), " ")
                strText = strText.Replace(Chr(10), " ")
                strText &= vbCrLf & vbCrLf
                strOut &= strText
            Next
            txtIndicators.Text = strOut.Substring(0, strOut.Length - 2)
        End With
        dsTemp.Dispose()

    End Sub

    Private Sub GetTherepeutics()
        Dim dsTemp As DataSet
        Dim strText As String = ""
        Dim strOut As String = ""
        dsTemp = FillDataSet("Select Theraputic from tblDrugTheraputics where DrugID=" & mlngRecordID)
        With dsTemp.Tables(0)
            'If .Rows.Count > 0 Then
            '    txtTherapeutic.Text = .Rows(0).Item("Theraputic")
            'End If
            For intCtr As Integer = 0 To .Rows.Count - 1
                strText = .Rows(intCtr).Item("Theraputic")
                strText = strText.Replace(Chr(13), " ")
                strText = strText.Replace(Chr(10), " ")
                strText &= vbCrLf & vbCrLf
                strOut &= strText
            Next
            txtTherapeutic.Text = strOut.Substring(0, strOut.Length - 2)
        End With
        dsTemp.Dispose()
    End Sub

    Private Sub GetContraIndicators()
        Dim dsTemp As DataSet
        Dim strText As String = ""
        Dim strOut As String = ""
        dsTemp = FillDataSet("Select ContraIndicator from tblDrugContraIndicator where DrugID=" & mlngRecordID)
        With dsTemp.Tables(0)
            'If .Rows.Count > 0 Then
            '    txtContraIndicators.Text = .Rows(0).Item("ContraIndicator")
            'End If
            For intCtr As Integer = 0 To .Rows.Count - 1
                strText = .Rows(intCtr).Item("ContraIndicator")
                strText = strText.Replace(Chr(13), " ")
                strText = strText.Replace(Chr(10), " ")
                strText &= vbCrLf & vbCrLf
                strOut &= strText
            Next
            txtContraIndicators.Text = strOut.Substring(0, strOut.Length - 2)
        End With
        dsTemp.Dispose()
    End Sub

    Private Sub GetCautions()
        Dim dsTemp As DataSet
        Dim strText As String = ""
        Dim strOut As String = ""

        dsTemp = FillDataSet("Select Caution from tblDrugCaution where DrugID=" & mlngRecordID)
        With dsTemp.Tables(0)
            'If .Rows.Count > 0 Then
            '    txtCautions.Text = .Rows(0).Item("Caution")
            'End If
            For intCtr As Integer = 0 To .Rows.Count - 1
                strText = .Rows(intCtr).Item("Caution")
                strText = strText.Replace(Chr(13), " ")
                strText = strText.Replace(Chr(10), " ")
                strText &= vbCrLf & vbCrLf
                strOut &= strText
            Next
            txtCautions.Text = strOut.Substring(0, strOut.Length - 2)
        End With
        dsTemp.Dispose()
    End Sub

    Private Sub GetActions()
        Dim dsTemp As DataSet
        Dim strText As String = ""
        Dim strOut As String = ""

        dsTemp = FillDataSet("Select Action from tblDrugActions where DrugID=" & mlngRecordID)
        With dsTemp.Tables(0)
            'If .Rows.Count > 0 Then
            '    txtActions.Text = .Rows(0).Item("Action")
            'End If
            For intCtr As Integer = 0 To .Rows.Count - 1
                strText = .Rows(intCtr).Item("Action")
                strText = strText.Replace(Chr(13), " ")
                strText = strText.Replace(Chr(10), " ")
                strText &= vbCrLf & vbCrLf
                strOut &= strText
            Next
            txtActions.Text = strOut.Substring(0, strOut.Length - 2)
        End With
        dsTemp.Dispose()


    End Sub

    Private Sub GetSideEffects()
        Dim dsTemp As DataSet
        dsTemp = FillDataSet("Select DrugSideEffectID [ID],Area,Siginificance [Significance],SideEffect [Effect] from tblDrugSideEffects where DrugID=" & mlngRecordID)
        With grdSideEffects
            .BeginUpdate()
            .DataSource = dsTemp.Tables(0)
            .EndUpdate()
        End With
        dsTemp.Dispose()
    End Sub
    Private Sub GetDose()
        Dim dsTemp As DataSet
        dsTemp = FillDataSet("Select DrugDosageID [ID],Route [Route],AdultChild [Age Group],AgeWeight [Restrictions],DrugDosage [Dose] from tblDrugDosage where DrugID=" & mlngRecordID)
        With grdDosage
            .BeginUpdate()
            .DataSource = dsTemp.Tables(0)
            .EndUpdate()
        End With
        dsTemp.Dispose()
    End Sub
    Public Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Call EnableDisableControls(True)

        If mstrMode = "Add" Then
            If gdvRecords.RowCount > 0 Then
                mlngRecordID = lngGetSelectID(gdvRecords, "record_id")
                DisplayData()
            Else
                ClearControls()
                btnEdit.Enabled = False : btnDelete.Enabled = False : btnPreview.Enabled = False
            End If
        Else
            If gdvRecords.RowCount = 0 Then
                ClearControls()
                btnEdit.Enabled = False : btnDelete.Enabled = False : btnPreview.Enabled = False
            Else
                DisplayData()
            End If
        End If

        Me.Text = "Drug Details"
        mstrMode = ""
        mblnChanged = False
    End Sub

    Private Sub EnableDisableControls(ByVal blnEnable As Boolean)
        If blnAdd = True Then btnAdd.Enabled = blnEnable
        If blnEdit = True Then btnEdit.Enabled = blnEnable
        If blnDelete = True Then btnDelete.Enabled = blnEnable

        btnSave.Enabled = Not (blnEnable) : btnCancel.Enabled = Not (blnEnable)

        If mblnIsImported = True Then
            MakeControlsReadOnly(True)
            gdvDosage.OptionsBehavior.Editable = False
            grdDosage.UseEmbeddedNavigator = False
            gdvSideEffects.OptionsBehavior.Editable = False
            grdSideEffects.UseEmbeddedNavigator = False
        Else
            grbControls.Enabled = Not (blnEnable)
            MakeControlsReadOnly(False)
            gdvDosage.OptionsBehavior.Editable = Not (blnEnable)
            grdDosage.UseEmbeddedNavigator = Not (blnEnable)
            gdvSideEffects.OptionsBehavior.Editable = Not (blnEnable)
            grdSideEffects.UseEmbeddedNavigator = Not (blnEnable)
        End If
    End Sub

    Public Sub MakeControlsReadOnly(ByVal blnReadOnly As Boolean)
        txtDrugName.Properties.ReadOnly = blnReadOnly
        txtTherapeuticClass.Properties.ReadOnly = blnReadOnly
        txtCategory.Properties.ReadOnly = blnReadOnly
        txtPharmacyClass.Properties.ReadOnly = blnReadOnly
        txtTherapeutic.Properties.ReadOnly = blnReadOnly
        txtIndicators.Properties.ReadOnly = blnReadOnly
        txtActions.Properties.ReadOnly = blnReadOnly
        txtContraIndicators.Properties.ReadOnly = blnReadOnly
        txtCautions.Properties.ReadOnly = blnReadOnly
    End Sub

    Private Sub gdvRecords_ColumnFilterChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles gdvRecords.ColumnFilterChanged
        gdvRecords.Columns(1).SummaryItem.SetSummary(DevExpress.Data.SummaryItemType.Count, "Total {0} Record(s)")

        Dim lngTemp As Long = lngGetSelectID(gdvRecords, "record_id")
        If mlngRecordID <> lngTemp Or btnCancel.Enabled = True Then
            gdvRecords_FocusedRowChanged(Nothing, Nothing)
        End If
    End Sub

    Private Sub gdvRecords_CustomDrawRowIndicator(ByVal sender As Object, ByVal e As DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs) Handles gdvRecords.CustomDrawRowIndicator
        SetRowIndicator(e)
    End Sub

    Private Sub gdvRecords_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles gdvRecords.DoubleClick
        If btnEdit.Enabled = True Then
            Call btnEdit_Click(Nothing, Nothing)
        End If
    End Sub

    Private Sub gdvRecords_FocusedRowChanged(ByVal sender As Object, ByVal e As DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs) Handles gdvRecords.FocusedRowChanged
        Try
            If mblnCancelDisplay = True Then Exit Sub

            mlngRecordID = lngGetSelectID(gdvRecords, "record_id")

            If gdvRecords.RowCount > 0 Then
                btnEdit.Enabled = blnEdit : btnDelete.Enabled = blnDelete
                btnPreview.Enabled = True
            Else
                ClearControls()
                btnEdit.Enabled = False : btnDelete.Enabled = False : btnPreview.Enabled = False
            End If
            btnAdd.Enabled = blnAdd

            If mlngRecordID = 0 Then Exit Sub

            If mblnExpanded = True Then Exit Sub

            Call btnCancel_Click(Nothing, Nothing)

        Catch ex As Exception
            MessageBox.Show(ex.Message, gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Error)
            Call AddErrorLog("Error " & Err.Number & " (" & Err.Description & ") in Procedure " & _
                 Reflection.MethodBase.GetCurrentMethod.Name & " Of " & Me.Name)
        End Try
    End Sub

    Private Sub gdvRecords_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles gdvRecords.GotFocus
        If btnCancel.Enabled = True And Me.Visible = True Then Call btnCancel_Click(Nothing, Nothing)
    End Sub

    Private Sub gdvRecords_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles gdvRecords.KeyDown
        Try

            If e.KeyCode = Keys.Delete And btnDelete.Enabled = True Then
                Call btnDelete_Click(Nothing, Nothing)
            ElseIf e.KeyCode = Keys.Return And btnDelete.Enabled = True Then
                Call gdvRecords_DoubleClick(Nothing, Nothing)
            ElseIf e.KeyCode = Keys.Escape Then
                Call btnClose_Click(Nothing, Nothing)
            End If

        Catch ex As Exception
            MessageBox.Show(ex.Message, gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Error)
            Call AddErrorLog("Error " & Err.Number & " (" & Err.Description & ") in Procedure " & _
                 Reflection.MethodBase.GetCurrentMethod.Name & " Of " & Me.Name)
        End Try
    End Sub

    Private Sub btnClose_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnClose.Click
        'If mblnActivate = False Then
        '    If mblnExpanded = False Then btnExpand_Click(Nothing, Nothing) Else Me.Close()
        'End If
        Me.Close()
    End Sub

    Public Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        Try
            If mblnExpanded = True Then btnExpand_Click(Nothing, Nothing)
            Call EnableDisableControls(False)
            Call ClearControls()
            mstrMode = "Add"
            mlngRecordID = 0
            Me.Text = "Drug Details [Add]"
            txtDrugName.Focus()
        Catch ex As Exception
            MessageBox.Show(ex.Message, gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Error)
            Call AddErrorLog("Error " & Err.Number & " (" & Err.Description & ") in Procedure " & _
                 Reflection.MethodBase.GetCurrentMethod.Name & " Of " & Me.Name)
        End Try
    End Sub

    Private Function IsValidEntry() As Boolean
        'Here check valid entry of fields
        Dim strMsg As String = ""
        IsValidEntry = False

        If Trim(txtDrugName.Text) = "" Then
            strMsg = "Please enter Drug Name"
            txtDrugName.Focus()
        End If


        If Trim(strMsg) <> "" Then
            IsValidEntry = False
            MessageBox.Show(strMsg, gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        Else
            IsValidEntry = True
        End If
    End Function

    Private Function blnSaveRecords() As Boolean
        Dim blnIsTransactionOpen As Boolean
        Try
            blnSaveRecords = False

            If IsValidEntry() = False Then
                Exit Function
            End If

            If (blnUnload = False) Then
                If (MessageBox.Show("Are you sure to " & IIf(mstrMode = "Add", "add", "modify") & " this specialist", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = System.Windows.Forms.DialogResult.No) Then
                    txtDrugName.Focus()
                    Exit Function
                End If
            End If

            gtrnWebPlusMed = gconWebPlusMed.BeginTransaction
            blnIsTransactionOpen = True

            Call SaveDrugDetail()

            SaveIndicators()

            SaveTherepeutics()

            SaveContraIndicators()

            SaveCautions()

            SaveActions()

            InsertSideEffects()

            InsertDose()

            blnSaveRecords = True

            gtrnWebPlusMed.Commit()
            blnIsTransactionOpen = False

        Catch ex As Exception
            If blnIsTransactionOpen = True Then
                gtrnWebPlusMed.Rollback()
            End If
            MessageBox.Show(ex.Message, gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Error)
            AddErrorLog("Error " & Err.Number & " (" & Err.Description & ") in Procedure " & _
                Reflection.MethodBase.GetCurrentMethod.Name & " Of " & Me.Name)
        End Try
    End Function
    Dim DrugId As Long
    Private Sub SaveDrugDetail()
        Dim objData As New DataAccess
        Try
            DrugId = objData.InsertDrug(txtDrugName.Text, txtCategory.Text, txtTherapeuticClass.Text, txtPharmacyClass.Text, False)
        Catch ex As SqlException
            MessageBox.Show(ex.Message, gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)

        End Try
    End Sub

    Private Sub SaveIndicators()
        Dim objData As New DataAccess
        Try
            DeleteFromTable("tblDrugIndications", "DrugId=" & DrugId)
            objData.InsertDrugIndication(DrugId, txtIndicators.Text)
        Catch ex As SqlException
            MessageBox.Show(ex.Message, gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        End Try
    End Sub

    Private Sub SaveTherepeutics()
        Dim objData As New DataAccess
        Try
            DeleteFromTable("tblDrugTheraputics", "DrugId=" & DrugId)
            objData.InsertDrugTheraputicEffect(DrugId, txtTheraPeutic.Text)
        Catch ex As SqlException
            MessageBox.Show(ex.Message, gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        End Try
    End Sub

    Private Sub SaveContraIndicators()
        Dim objData As New DataAccess
        Try
            DeleteFromTable("tblDrugContraIndicator", "DrugId=" & DrugId)
            objData.InsertDrugContraIndications(DrugId, txtContraIndicators.Text)
        Catch ex As SqlException
            MessageBox.Show(ex.Message, gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        End Try
    End Sub

    Private Sub SaveCautions()
        Dim objData As New DataAccess
        Try
            DeleteFromTable("tblDrugCaution", "DrugId=" & DrugId)
            objData.InsertDrugCaution(DrugId, txtCautions.Text)
        Catch ex As SqlException
            MessageBox.Show(ex.Message, gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        End Try
    End Sub

    Private Sub SaveActions()
        Dim objData As New DataAccess
        Try
            DeleteFromTable("tblDrugActions", "DrugId=" & DrugId)
            objData.InsertDrugAction(DrugId, txtActions.Text)
        Catch ex As SqlException
            MessageBox.Show(ex.Message, gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        End Try
    End Sub

    Private Sub InsertSideEffects()
        'Delete all diagnosis for this Visitsfirst
        Dim cn As New SqlConnection(gstrConnectionString)
        Try
            Call DeleteFromTable("tblDrugSideEffects", "DrugId=" & DrugId)
        Catch ex As Exception
            MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try

        Dim dt As DataTable = grdSideEffects.DataSource

        Dim dcInsert As New SqlCommand
        dcInsert.CommandText = "INSERT INTO tblDrugSideEffects(DrugID,SideEffect,Area,Siginificance) VALUES (@DrugID,@SideEffect,@Area,@Siginificance)"
        dcInsert.Connection = cn
        dcInsert.Parameters.Add(New SqlParameter("@DrugID", SqlDbType.Int, 4, "DrugID"))
        dcInsert.Parameters.Add(New SqlParameter("@SideEffect", SqlDbType.VarChar, 1000, "SideEffect"))
        dcInsert.Parameters.Add(New SqlParameter("@Area", SqlDbType.VarChar, 50, "Area"))
        dcInsert.Parameters.Add(New SqlParameter("@Siginificance", SqlDbType.VarChar, 50, "Significance"))

        Try
            cn.Open()
            For Each r As DataRow In dt.Rows
                With dcInsert
                    .Parameters("@DrugID").Value = DrugId
                    .Parameters("@SideEffect").Value = r.Item("Effect")
                    .Parameters("@Area").Value = r.Item("Area")
                    .Parameters("@Siginificance").Value = r.Item("Significance")
                    .ExecuteNonQuery()
                End With
            Next
        Catch ex As SqlException
            MessageBox.Show(ex.Message, gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        End Try
    End Sub

    Private Sub InsertDose()
        'Delete all diagnosis for this Visitsfirst
        Dim cn As New SqlConnection(gstrConnectionString)
        Try
            Call DeleteFromTable("tblDrugDosage", "DrugId=" & DrugId)
        Catch ex As SqlException
            MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try

        Dim dt As DataTable = grdDosage.DataSource

        Dim dcInsert As New SqlCommand
        dcInsert.CommandText = "INSERT INTO tblDrugDosage(DrugID,DrugDosage,AdultChild,Route,AgeWeight) VALUES (@DrugID,@DrugDosage ,@AdultChild ,@Route ,@AgeWeight)"
        dcInsert.Connection = cn
        dcInsert.Parameters.Add(New SqlParameter("@DrugID", SqlDbType.Int, 4, "DrugID"))
        dcInsert.Parameters.Add(New SqlParameter("@DrugDosage", SqlDbType.VarChar, 1000, "DrugDosage"))
        dcInsert.Parameters.Add(New SqlParameter("@AdultChild", SqlDbType.VarChar, 50, "AdultChild"))
        dcInsert.Parameters.Add(New SqlParameter("@Route", SqlDbType.VarChar, 50, "Route"))
        dcInsert.Parameters.Add(New SqlParameter("@AgeWeight", SqlDbType.VarChar, 50, "AgeWeight"))

        Try
            cn.Open()
            For Each r As DataRow In dt.Rows
                With dcInsert
                    .Parameters("@DrugID").Value = DrugId
                    .Parameters("@DrugDosage").Value = r.Item("Dose")
                    .Parameters("@AdultChild").Value = r.Item("Age Group")
                    .Parameters("@Route").Value = r.Item("Route")
                    .Parameters("@AgeWeight").Value = r.Item("Restrictions")
                    .ExecuteNonQuery()
                End With
            Next
        Catch ex As SqlException
            MessageBox.Show(ex.Message, gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        End Try
    End Sub

    Public Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
        Dim lngTemp As Long, lngRowID As Long
        Try
            If mblnChanged = False Then
                Call btnCancel_Click(Nothing, Nothing)
                Exit Sub
            End If
            If blnSaveRecords() = False Then Exit Sub
            If mstrMode = "Add" Then
                mlngRecordID = GetId("tblDrugs")
            End If

            'If mblnChanged = False Then
            '    Call btnCancel_Click(Nothing, Nothing)
            'Else
            lngTemp = mlngRecordID

            pbRecords.Visible = True
            pbRecords.BringToFront()
            Application.DoEvents()
            pbRecords.Position = 20

            gdvRecords.OptionsSelection.EnableAppearanceFocusedRow = False
            gdvRecords.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.None
            mblnCancelDisplay = True
            Call PopulateData()
            mblnCancelDisplay = False

            pbRecords.Position = 95
            If gdvRecords.RowCount > 0 Then
                lngRowID = LocateRowBySingleValue(grdRecords, lngTemp)
                gdvRecords.FocusedRowHandle = lngRowID
                If lngRowID = 0 Then gdvRecords_FocusedRowChanged(Nothing, Nothing)
            Else
                Call btnCancel_Click(Nothing, Nothing)
            End If
            gdvRecords.OptionsSelection.EnableAppearanceFocusedRow = True
            gdvRecords.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus

            pbRecords.Position = 100
            pbRecords.Visible = False
            'End If
        Catch ex As Exception
            pbRecords.Visible = False
            MessageBox.Show(ex.Message, gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Error)
            Call AddErrorLog("Error " & Err.Number & " (" & Err.Description & ") in Procedure " & _
                 Reflection.MethodBase.GetCurrentMethod.Name & " Of " & Me.Name)
        End Try
    End Sub

    Public Sub btnPreview_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPreview.Click
        ShowGridPreview(grdRecords, Me.Text)
    End Sub

    Public Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click
        Try

            If mblnExpanded = True Then btnExpand_Click(Nothing, Nothing)

            Call EnableDisableControls(False)
            mblnChanged = False
            mstrMode = "Edit"
            Me.Text = "Drug Details [Edit]"
            txtDrugName.Focus()
            DrugId = mlngRecordID
        Catch ex As Exception
            MessageBox.Show(ex.Message, gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Error)
            Call AddErrorLog("Error " & Err.Number & " (" & Err.Description & ") in Procedure " & _
                 Reflection.MethodBase.GetCurrentMethod.Name & " Of " & Me.Name)
        End Try
    End Sub

    Private Sub gdvRecords_RowCellStyle(ByVal sender As Object, ByVal e As DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs) Handles gdvRecords.RowCellStyle
        Dim view As GridView = sender
        If e.CellValue Is System.DBNull.Value = True Then Exit Sub
        Dim fnBold As New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Bold)
        Dim fnbold1 As New System.Drawing.Font("Tahoma", 10.0!, FontStyle.Bold)
        If view.GetRowCellValue(e.RowHandle, view.Columns("IsImported")) = "False" Then
            e.Appearance.Font = fnBold
            e.Appearance.ForeColor = Color.Tomato
        End If
        If e.Appearance.ForeColor = Color.Tomato And e.Column Is gdvRecords.FocusedColumn Then
            If e.RowHandle = gdvRecords.FocusedRowHandle Then
                e.Appearance.ForeColor = Color.White
            End If
        End If
    End Sub

    Private Sub gdvRecords_ShowGridMenu(ByVal sender As Object, ByVal e As DevExpress.XtraGrid.Views.Grid.GridMenuEventArgs) Handles gdvRecords.ShowGridMenu
        If e.MenuType = DevExpress.XtraGrid.Views.Grid.GridMenuType.Column Then
            Dim mainMenu As DevExpress.XtraGrid.Menu.ViewMenu = CType(e.Menu, DevExpress.XtraGrid.Menu.ViewMenu)
            Dim mainItem As New DevExpress.Utils.Menu.DXMenuItem("Column Auto Width", New EventHandler(AddressOf MainMenuItem))
            mainItem.BeginGroup = True
            mainItem.Tag = e.Menu
            mainMenu.Items.Add(mainItem)
            mainItem.Image = IIf(mblnAutoSize = True, mdiMain.imgEditIcons.Images(13), Nothing)
        End If
    End Sub

    Private Sub MainMenuItem(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim Item As DevExpress.Utils.Menu.DXMenuItem = CType(sender, DevExpress.Utils.Menu.DXMenuItem)
        Dim menu As DevExpress.XtraGrid.Menu.GridViewMenu = CType(Item.Tag, DevExpress.XtraGrid.Menu.GridViewMenu)
        mblnAutoSize = Not (mblnAutoSize)
        gdvRecords.OptionsView.ColumnAutoWidth = (mblnAutoSize = True)
        If gdvRecords.OptionsView.ColumnAutoWidth = False Then gdvRecords.BestFitColumns()
    End Sub

    Private Sub txtFirstName_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtDrugName.GotFocus, txtCategory.GotFocus, txtTherapeuticClass.GotFocus, txtPharmacyClass.GotFocus
        sender.SelectAll()
    End Sub

    Private Sub ClearControls()
        Try
            Call InitialiseDosage()
            Call InitialiseSideEffect()
            Call Clearfields(grbControls)

        Catch ex As Exception
            MessageBox.Show(ex.Message, gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Error)
            Call AddErrorLog("Error " & Err.Number & " (" & Err.Description & ") in Procedure " & _
                 Reflection.MethodBase.GetCurrentMethod.Name & " Of " & Me.Name)
        End Try
    End Sub

    Public Sub SetRowFromOutside(ByVal RecID As Long)
        Dim lngRowID As Long
        gdvRecords.OptionsSelection.EnableAppearanceFocusedRow = False
        gdvRecords.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.None
        lngRowID = LocateRowBySingleValue(grdRecords, RecID)
        gdvRecords.FocusedRowHandle = lngRowID
        If lngRowID = 0 Then gdvRecords_FocusedRowChanged(Nothing, Nothing)
        gdvRecords.OptionsSelection.EnableAppearanceFocusedRow = True
        gdvRecords.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus
    End Sub

    Private Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDelete.Click
        Dim blnTrnasaction As Boolean

        Try

            If MessageBox.Show("Are you sure you want to permanently delete this record", gstrMessage, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
                gtrnWebPlusMed = gconWebPlusMed.BeginTransaction
                blnTrnasaction = True
                'Call DeleteFromTable("tblSpecialists", "DoctorId=" & mlngRecordID)
                Call UpdateTable("tblDrugs", "DrugDeleted=1", "DrugId=" & mlngRecordID)
                gtrnWebPlusMed.Commit()
                blnTrnasaction = False
                MessageBox.Show("Record deleted", gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Information)
                SendKeys.Send("{F5}")
            End If


        Catch ex As Exception
            If blnTrnasaction = True Then
                gtrnWebPlusMed.Rollback()
            End If
            MessageBox.Show("Record in use" & vbCrLf & "Cannot delete", gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Error)
            Call AddErrorLog("Error " & Err.Number & " (" & Err.Description & ") in Procedure " & _
                 Reflection.MethodBase.GetCurrentMethod.Name & " Of " & Me.Name)
        End Try
    End Sub

    Private Sub lkDrug_EditValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lkDrug.EditValueChanged, lkPharmacyClass.EditValueChanged, lkTherapeuticClass.EditValueChanged
        SendKeys.Send("{F5}")
    End Sub

    Private Sub InitialiseSideEffect()
        Dim dtTemp As DataTable
        dtTemp = New DataTable("Side Effect")
        With dtTemp.Columns
            .Add("ID", GetType(Integer))
            .Add("Area", GetType(String))
            .Add("Significance", GetType(String))
            .Add("Effect", GetType(String))
        End With
        grdSideEffects.DataSource = dtTemp
        gdvSideEffects.Columns("ID").Visible = False
        dtTemp.Dispose()
    End Sub

    Private Sub SetEditorSideEffect()
        Try

            Call InitialiseSideEffect()

            Dim fnBold As New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Bold)
            With gdvSideEffects

                .Columns("ID").Visible = False
                .Columns("ID").OptionsColumn.ShowInCustomizationForm = False
                .Columns("Area").AppearanceHeader.Font = fnBold
                .Columns("Significance").MinWidth = 65
                .Columns("Effect").MinWidth = 65
                .OptionsView.ColumnAutoWidth = True
            End With

        Catch ex As Exception
            MessageBox.Show(ex.Message, gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Error)
            Call AddErrorLog("Error " & Err.Number & " (" & Err.Description & ") in Procedure " & _
                 Reflection.MethodBase.GetCurrentMethod.Name & " Of " & Me.Name)
        End Try
    End Sub

    Private Sub InitialiseDosage()
        Dim dtTemp As DataTable
        dtTemp = New DataTable("Dosage")
        With dtTemp.Columns
            .Add("ID", GetType(Integer))
            .Add("Route", GetType(String))
            .Add("Age Group", GetType(String))
            .Add("Restrictions", GetType(String))
            .Add("Dose", GetType(String))
        End With
        grdDosage.DataSource = dtTemp
        gdvDosage.Columns("ID").Visible = False
        dtTemp.Dispose()
    End Sub

    Private Sub SetEditorDosage()
        Try

            Call InitialiseDosage()

            Dim fnBold As New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Bold)
            With gdvDosage

                .Columns("ID").Visible = False
                .Columns("ID").OptionsColumn.ShowInCustomizationForm = False
                .Columns("Route").AppearanceHeader.Font = fnBold
                .Columns("Age Group").MinWidth = 65
                .Columns("Dose").MinWidth = 100
                .OptionsView.ColumnAutoWidth = True
            End With

        Catch ex As Exception
            MessageBox.Show(ex.Message, gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Error)
            Call AddErrorLog("Error " & Err.Number & " (" & Err.Description & ") in Procedure " & _
                 Reflection.MethodBase.GetCurrentMethod.Name & " Of " & Me.Name)
        End Try
    End Sub

    Private Sub rgSelect_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rgSelect.SelectedIndexChanged
        If rgSelect.SelectedIndex = 0 Then
            lblSelect.Text = "Select Drug Name"
            lkDrug.Visible = True
            lkTherapeuticClass.Visible = False
            lkPharmacyClass.Visible = False
        ElseIf rgSelect.SelectedIndex = 1 Then
            lblSelect.Text = "Select Therapeutic Name"
            lkDrug.Visible = False
            lkTherapeuticClass.Visible = True
            lkPharmacyClass.Visible = False
        ElseIf rgSelect.SelectedIndex = 2 Then
            lblSelect.Text = "Select Pharmacy Name"
            lkDrug.Visible = False
            lkTherapeuticClass.Visible = False
            lkPharmacyClass.Visible = True
        End If
    End Sub

    Private Sub txtTherapeutic_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtTherapeutic.KeyDown
        If e.KeyCode = Keys.Return Then
            Call NotesFocus(txtTherapeutic)
        End If
    End Sub

    Private Sub txtTherapeutic_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtTherapeutic.Validated
        sender.Text = TrimX(sender.Text)
    End Sub

    Private Sub txtIndicators_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtIndicators.KeyDown
        If e.KeyCode = Keys.Return Then
            Call NotesFocus(txtIndicators)
        End If
    End Sub

    Private Sub txtIndicators_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtIndicators.Validated
        sender.text = TrimX(sender.Text)
    End Sub

    Private Sub txtActions_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtActions.KeyDown
        If e.KeyCode = Keys.Return Then
            Call NotesFocus(txtActions)
        End If
    End Sub

    Private Sub txtActions_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtActions.TextChanged, txtCategory.TextChanged, txtCautions.TextChanged, txtContraIndicators.TextChanged, txtDrugName.TextChanged, txtIndicators.TextChanged, txtPharmacyClass.TextChanged, txtTherapeutic.TextChanged, txtTherapeuticClass.TextChanged
        mblnChanged = True
    End Sub

    Private Sub txtActions_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtActions.Validated
        sender.text = TrimX(sender.Text)
    End Sub

    Private Sub txtContraIndicators_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtContraIndicators.KeyDown
        If e.KeyCode = Keys.Return Then
            Call NotesFocus(txtContraIndicators)
        End If
    End Sub

    Private Sub txtContraIndicators_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtContraIndicators.Validated
        sender.text = TrimX(sender.Text)
    End Sub

    Private Sub txtCautions_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtCautions.KeyDown
        If e.KeyCode = Keys.Return Then
            Call NotesFocus(txtCautions)
        End If
    End Sub

    Private Sub txtCautions_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtCautions.Validated
        sender.text = TrimX(sender.Text)
    End Sub

    Private Sub gdvSideEffects_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles gdvSideEffects.KeyDown
        If IsDBNullOrNothing(gdvSideEffects.GetRowCellValue(gdvSideEffects.FocusedRowHandle, "Area")) And IsDBNullOrNothing(gdvSideEffects.GetRowCellValue(gdvSideEffects.FocusedRowHandle, "Significance")) And IsDBNullOrNothing(gdvSideEffects.GetRowCellValue(gdvSideEffects.FocusedRowHandle, "Effect")) Then
            e.Handled = True
            gdvDosage.Focus()
            gdvDosage.FocusedColumn = gdvDosage.VisibleColumns(0)
            gdvDosage.ShowEditor()
        End If
    End Sub

    Private Sub gdvDosage_CellValueChanged(ByVal sender As Object, ByVal e As DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs) Handles gdvDosage.CellValueChanged
        mblnChanged = True
    End Sub

    Private Sub gdvDosage_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles gdvDosage.KeyDown
        If IsDBNullOrNothing(gdvDosage.GetRowCellValue(gdvDosage.FocusedRowHandle, "Route")) And IsDBNullOrNothing(gdvDosage.GetRowCellValue(gdvDosage.FocusedRowHandle, "Age Group")) And IsDBNullOrNothing(gdvDosage.GetRowCellValue(gdvDosage.FocusedRowHandle, "Restrictions")) And IsDBNullOrNothing(gdvDosage.GetRowCellValue(gdvDosage.FocusedRowHandle, "Dose")) Then
            e.Handled = True
            btnSave.Focus()
        End If
    End Sub

    Private Sub gdvSideEffects_CellValueChanged(ByVal sender As System.Object, ByVal e As DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs) Handles gdvSideEffects.CellValueChanged
        mblnChanged = True
    End Sub
End Class
